clipboard: Add get_default() helper
authorJonas Danielsson <jonas@threetimestwo.org>
Wed, 20 Nov 2013 16:25:59 +0000 (17:25 +0100)
committerBastien Nocera <hadess@hadess.net>
Tue, 27 Jan 2015 17:09:31 +0000 (18:09 +0100)
Add helper for getting the main clipboard. This makes
the API usable for bindings (as GdkAtoms aren't usable through
gobject-introspection), and easier to use in C.

https://bugzilla.gnome.org/show_bug.cgi?id=712752

docs/reference/gtk/gtk3-sections.txt
gtk/gtkclipboard.c
gtk/gtkclipboard.h

index be4e6321cef104799d3f3f8ba1d1935319ac4645..748f1be6ab5b617a3b23f784d991ceac12a286dd 100644 (file)
@@ -6476,6 +6476,7 @@ GtkClipboardClearFunc
 gtk_clipboard_get
 gtk_clipboard_get_for_display
 gtk_clipboard_get_display
+gtk_clipboard_get_default
 gtk_clipboard_set_with_data
 gtk_clipboard_set_with_owner
 gtk_clipboard_get_owner
index 302f7f73f1acde06959906eefb7f6a75dbc1d208..d2381beb309d79a09e47d782237b3999ce95e4f7 100644 (file)
@@ -378,6 +378,26 @@ gtk_clipboard_get (GdkAtom selection)
   return gtk_clipboard_get_for_display (gdk_display_get_default (), selection);
 }
 
+/**
+ * gtk_clipboard_get_default:
+ * @display: the #GdkDisplay for which the clipboard is to be retrieved.
+ *
+ * Returns the default clipboard object for use with cut/copy/paste menu items
+ * and keyboard shortcuts.
+ *
+ * Return value: (transfer none): the default clipboard object.
+ *
+ * Since: 3.16
+ **/
+GtkClipboard *
+gtk_clipboard_get_default (GdkDisplay *display)
+{
+  g_return_val_if_fail (display != NULL, NULL);
+  g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
+
+  return gtk_clipboard_get_for_display (display, GDK_SELECTION_CLIPBOARD);
+}
+
 static void 
 selection_get_cb (GtkWidget          *widget,
                  GtkSelectionData   *selection_data,
index e59a45093cc9108bc629b311b5059e1cf947d766..5470de405b5bde716b464299556510934affa340 100644 (file)
@@ -189,6 +189,9 @@ GtkClipboard *gtk_clipboard_get_for_display (GdkDisplay   *display,
 GDK_AVAILABLE_IN_ALL
 GtkClipboard *gtk_clipboard_get             (GdkAtom       selection);
 
+GDK_AVAILABLE_IN_3_16
+GtkClipboard *gtk_clipboard_get_default     (GdkDisplay    *display);
+
 GDK_AVAILABLE_IN_ALL
 GdkDisplay   *gtk_clipboard_get_display     (GtkClipboard *clipboard);